<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数据分析</title>

  <link rel="stylesheet" href="/fission/css/iconfont.css">
  <link rel="stylesheet" href="/layui/css/layui.css">
  <link rel="stylesheet" href="/fission/css/common.css">
  <link rel="stylesheet" href="/fission/css/index.css">
  <link rel="stylesheet" href="/hyqcss/public.css">
  <style>
   
</style>
<style type="text/css">
  .slide-btn{
    width:100px;
    display:inline-block;
    border:1px solid;
    border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
    border-radius:5px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
  }
  .slide-btn .inner-on,.slide-btn .inner-off{
    width:151px;
    box-sizing:border-box;
    display: inline-block;
    position: relative;
    left:0;
    cursor: pointer;
    transition:left 0.5s;
  }
  .inner-on .left,.inner-off .left{
    width: 50px;
    color: #fff;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
    background:#58b058;
    text-align:center;
    display: inline-block;
    padding: 4px 0;
  }
  .inner-on .space,.inner-off .space{
    width: 51px;
    display: inline-block;
    box-sizing:border-box;
    padding: 4px 0;
    color: #fff;
    background-color: #f5f5f5;
    border-left: 1px solid #cccccc;
    border-right: 1px solid #cccccc;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
    background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
    border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
  }
  .inner-on .right,.inner-off .right{
    width: 50px;
    color: #fff;
    text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
    background:#f9a123;
    text-align:center;
    display: inline-block;
    padding: 4px 0;
  }
  .publicLabel{
    background: #FFF5E6;
    color: #D27711;
    padding: 4px 7px;
    border-radius: 2px;
  }
  .customSwitch .layui-form-switch{
    margin-top: 0 !important;
  }
  .layui-table tr{
    height: 48px;
  }
  /*表格切换区域 start*/
  .mission_switchTable_container{
    padding: 15px 16px;
    background: #fff;
    border-radius: 4px 4px 0px 0px;
  }
  .mission_switchTable{
    display: flex;
    align-items: center;
  }
  .mission_switchTable a{
    width: 140px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #D9DDE2;
    cursor: pointer;
    color: rgba(0,0,0,.65);
  }
  .mission_switchTable a:first-child{
    border-radius: 2px 0px 0px 2px;
    border-right: none;
  }
  .mission_switchTable a:last-child{
    border-radius: 0px 2px 2px 0px;
  }
  .mission_switchTable_active{
    background: #1890ff !important;
    color: #fff !important;
    border: 1px solid #1890ff !important;

  }
  .mission_switchTable_content{

  }
  .mission_switchTable_first_container{

  }
  .mission_switchTable_secend_container{

  }
  /*表格切换区域 end*/
</style>
</head>
<body>
  <div style="margin-top: 0;" class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
    <ul class="public-header-nav">
      <li><a class="public-header-nav-active" href="mission_list.html">任务列表</a></li>
      <li><a href="mission_statistics.html">数据分析</a></li>
      <li><a href="mission_xianzhi.html">区域限制配置</a></li>
      <li><a href="stage_prize.html">裂变兑换码</a></li>
      <li><a href="short_url.html">短链接配置</a></li>
    </ul>
    <div class="layui-tab-content" style="padding: 10px 16px;">
      <!-- 任务列表 Tab -->
      <div class="layui-tab-item layui-show">
        <div style="margin: 6px 0 16px 0;">
           {if $type == 1}
           <a href="create_mission.html" class="layui-btn layui-btn-normal" style="height: 32px; line-height: 32px;">+ 新建活动</a>
           {else}
           <a href="create_missions.html" class="layui-btn layui-btn-normal" style="height: 32px; line-height: 32px;">+ 新建活动</a>
           {/if}
           <span class="layui-btn layui-btn-primary" onclick="copyToClip('{$toolbarUrl}')">复制工具栏URL</span>
          
        </div>
        <section class="missions-container">
          <div class="mission_switchTable_container">
            <div class="mission_switchTable">
              <a href="mission_list.html" data-type="qw" {if $type == 1}class="mission_switchTable_active"{/if}>企微裂变</a>
              <a href="mission_list.html?type=2" data-type="gzh" {if $type == 2}class="mission_switchTable_active"{/if}>企微+公众号裂变</a>
            </div>
          </div>
          <div class="mission_switchTable_content">
            <!-- 第一个区域 -->
            <div class="mission_switchTable_first_container">
              <!-- 静态数据型 表格 -->
              <table class="layui-form layui-table" lay-skin="line" style="margin: 0">
                <colgroup>
                  <col>
                  <col>
                  <col>
                  <col width="120">
                  <col width="180">
                  <col width="150">
                  <col width="120">
                  <col width="260">
                </colgroup>
                <thead>
                  <tr style="background: #f0f2f5; height: 48px;">
                    <th style="padding-left: 10px;">活动名称</th>
                    <th>使用成员</th>
                    <th>活动客户标签</th>
                    <th>扫码添加人数</th>
                    <th>创建时间</th>
                    <th>活动状态</th>
                    <th>欢迎语状态</th>
                    <th>操作</th>
                  </tr>
                </thead>
                <tbody>
                  {loop $res as $r}
                  <tr>
                    <td>{$r['name']}</td>
                    <td>
                      {loop json_decode($r['users'],1) as $user}
                        {$h->get_user_by_id($r['wid'],$user)['name']}
                      {/loop}
                    </td>
                    <td>{loop json_decode($r['select_label'],1) as $tag} {if $h->get_et_tags($r['wid'])[$tag]}
                      <span class="publicLabel">{$h->get_et_tags($r['wid'])[$tag]}</span>{/if} {/loop}
                    </td>
                    <td>{$r['allCustomer']}</td>
                    <td>{$r['ctime']}</td>
                    <td>{if time() > $r['end_time']}已结束{else if $r["status"] == 2}公众号已解绑{else}进行中{/if}</td>
                    <td>
                      <div class="customSwitch">
                        <input type="checkbox" lay-filter="switch1" lay-skin="switch" data-id="{$r['id']}" {if $r['hyy_status'] == 1}checked{/if}>
                      </div>
                      <!-- <div class="slide-btn">

                        <div data-id="{$r['id']}" {if $r['hyy_status'] == 1} style="left :-51px;"class="inner-off inner"{else} class="inner-on inner" {/if}>
                          <span class="left">已关闭</span><span class="space">&nbsp;</span><span class="right">已开启</span>
                        </div> -->
                      </td> 
                      <td>
                        <a style="margin-right: 15px;" {if time()>$r['end_time'] || $r["status"] == 2}href="javascript::void(0)"{else}href="invitation-{$r['id']}.html"{/if} class="table-btn" lay-event="invitation">邀请客户参与</a>
                        <a style="margin-right: 15px;" class="table-btn table-btn-details" data-id="{$r['id']}" data-others="other" lay-event="details">详情</a>
                        {if $r['type'] == 1}
                        <a style="margin-right: 15px;" {if time()>$r['end_time'] || $r["status"] == 2}href="javascript::void(0)"{else}href="create_mission-{$r['id']}.html"{/if} class="table-btn" lay-event="edit">修改</a>{else}
                        <a style="margin-right: 15px;" {if time()>$r['end_time'] || $r["status"] == 2}href="javascript::void(0)"{else}href="create_missions-{$r['id']}.html"{/if} class="table-btn" lay-event="edit">修改</a>{/if}
                        
                        <a class="table-btn" onclick="del_mission({$r['id']})">删除</a>
                      </td>
                    </tr>
                    {/loop}
                  </tbody>
              </table>
              <div class="main-container-h pageing-container-h" style="padding-top: 20px;">
                <div class="pageing-content-h">
                     <span>{$count[0]["count(*)"]}条/{$counts}页</span> 
                </div>
                <ul class="pageing-content-h">
                <!-- {P weidogsadmin} -->
                {if $type == 2}
                    {if $page != 0}
                    <a href="mission_list.html?page=0&type=2" target='_self'>首页</a>
                    <a href="mission_list.html?page={$page-1}&type=2" target='_self'>上一页</a>
                    {/if}
                    <?php for($i=0;$i<$counts;$i++){
                         $size = $i+1;
                         if($page + 1 == $size){
                              echo "<a href='mission_list.html?page=$i&type=2' target='_self' class='number current'>".$size."</a>";
                         }else{
                              echo "<a href='mission_list.html?page=$i&type=2' target='_self'>".$size."</a>";
                         }
                    }?>
                    {if $counts > $page+1}
                    <a href="mission_list.html?page={$page+1}&type=2" target='_self'>下一页</a>
                    <a href="mission_list.html?page={$counts-1}&type=2" target='_self'>尾页</a>
                    {/if}
                {else}
                    {if $page != 0}
                    <a href="mission_list.html?page=0" target='_self'>首页</a>
                    <a href="mission_list.html?page={$page-1}" target='_self'>上一页</a>
                    {/if}
                    <?php for($i=0;$i<$counts;$i++){
                         $size = $i+1;
                         if($page + 1 == $size){
                              echo "<a href='mission_list.html?page=$i' target='_self' class='number current'>".$size."</a>";
                         }else{
                              echo "<a href='mission_list.html?page=$i' target='_self'>".$size."</a>";
                         }
                    }?>
                    {if $counts > $page+1}
                    <a href="mission_list.html?page={$page+1}" target='_self'>下一页</a>
                    <a href="mission_list.html?page={$counts-1}" target='_self'>尾页</a>
                    {/if}
               {/if}
                </ul>
              </div>
            </div>
            <!-- 第二个区域 -->
            <!--<div class="mission_switchTable_secend_container" style="display: none">
              <table class="layui-table" lay-skin="line">
                <colgroup>
                  <col>
                  <col>
                  <col>
                  <col width="120">
                  <col>
                  <col width="120">
                  <col width="260">
                  <col>
                </colgroup>
                <thead>
                  <tr>
                    <th>活动名称1</th>
                    <th>使用成员</th>
                    <th>活动客户标签</th>
                    <th>扫码添加人数</th>
                    <th>创建时间</th>
                    <th>活动状态</th>
                    <th>欢迎语状态</th>
                    <th>操作</th>
                  </tr>
                </thead>
                <tbody>
                  {loop $res as $r}
                  <tr>
                    <td>{$r->name}</td>
                    <td>{loop json_decode($r->users,1) as $user}
                      <div class="service-card">
                        <i class="iconfont icon-person"></i>{$h->get_user_by_id($r->wid,$user)['name']}
                      </div>{/loop}
                    </td>
                    <td>{loop json_decode($r->select_label,1) as $tag} {if $h->get_et_tags($r->wid)[$tag]}
                      <span class="layui-badge layui-bg-blue">{$h->get_et_tags($r->wid)[$tag]}</span>{/if} {/loop}
                    </td>
                    <td>{$r->allCustomer}</td>
                    <td>{$r->ctime}</td>
                    <td>{if time() > $r->end_time}已结束{else}进行中{/if}</td>
                    <td>
                      <div class="slide-btn">
                        <div data-id="{$r->id}" {if $r->hyy_status == 1} style="left :-51px;"class="inner-off inner"{else} class="inner-on inner" {/if}>
                          <span class="left">已关闭</span>
                          <span class="space">&nbsp;</span>
                          <span class="right">已开启</span></div>
                        </div>
                      </td>
                      <td>
                        <a {if time()>$r->end_time}href="javascript::void(0)"{else}href="invitation-{$r->id}.html"{/if} class="table-btn" lay-event="invitation">邀请客户参与</a>
                        <div class="divider-vertical"></div>
                        <a class="table-btn table-btn-details" data-id="{$r->id}" data-others="other" lay-event="details">详情</a>
                        <div class="divider-vertical"></div>{if $r->type == 1}
                        <a {if time()>$r->end_time}href="javascript::void(0)"{else}href="create_mission-{$r->id}.html"{/if} class="table-btn" lay-event="edit">修改</a>{else}
                        <a {if time()>$r->end_time}href="javascript::void(0)"{else}href="create_missions-{$r->id}.html"{/if} class="table-btn" lay-event="edit">修改</a>{/if}
                        <div class="divider-vertical"></div>
                        <a class="table-btn" onclick="del_mission({$r->id})">删除</a>
                      </td>
                    </tr>
                    {/loop}
                  </tbody>
              </table>
              <div class="main-container-h pageing-container-h">
                <div class="pageing-content-h">
                  <span>{$p->totalnum}条/{$p->totalpage}页</span>
                </div>
                <ul class="pageing-content-h">{P weidogsadmin}</ul>
              </div>
            </div>-->
          </div>

   </section>
 </div>
 <!-- 数据分析 Tab -->
<!-- <div class="layui-tab-item">
  <form style="margin: 5px 20px;" class="layui-form">
    <div class="layui-inline">
      <label style="width: auto;padding-left: 0;" class="layui-form-label">当前活动：</label>
      <div class="layui-input-inline">
        <select name="mission" lay-search="" lay-filter="mission">
         {loop $missionArr as $id=>$name}
         <option value="{$id}">{$name}</option>
         {/loop}
              </select>
            </div>
            <span class="layui-badge layui-bg-green" id="missionStatus">{if time() > $missionFirst->end_time}活动已结束{else}活动进行中{/if}</span>
          </div>
        </form>

        <section style="padding: 20px;" class="public-container">
          <section class="flex align-items-center data-sum">
            <div class="flex-1 flex flex-column justify-center align-items-center data-sum-item">
              <p class="data-sum-value" id="allCustomer">{$allCustomer}</p>
              <p>邀请客户总数</p>
            </div>
            <div class="divider-vertical"></div>
            <div class="flex-1 flex flex-column justify-center align-items-center data-sum-item">
              <p class="data-sum-value" id="newCustomer">{$newCustomer}</p>
              <p>邀请新客户总数</p>
            </div>
            <div class="divider-vertical"></div>
            <div class="flex-1 flex flex-column justify-center align-items-center data-sum-item">
              <p class="data-sum-value" id="lossCustomer">{$lossCustomer}</p>
              <p>流失客户数</p>
            </div>
            <div class="divider-vertical"></div>
            <div class="flex-1 flex flex-column justify-center align-items-center data-sum-item">
              <p class="data-sum-value" id="growthCustomer">{$allCustomer - $lossCustomer}</p>
              <p>净增客户总数</p>
            </div>
            <div class="divider-vertical"></div>
            <div class="flex-1 flex flex-column justify-center align-items-center data-sum-item">
              <p class="data-sum-value" id="todayCustomer">{$todayCustomer}</p>
              <p>今日新增客户数</p>
            </div>
          </section>

          <div class="refresh-box">
            <strong id="allCustomers">共{$allCustomer}个客户</strong>
            <div style="margin: 0 10px;" class="divider-vertical"></div>
            
          </div>

          <form action="" class="layui-form">
            <div class="layui-form-item">
            </div>
          </form>

         
          <table class="layui-table">
            <colgroup>
              <col>
              <col>
              <col>
              <col width="120">
              <col width="120">
              <col width="120">
              <col width="170">
              <col>
            </colgroup>
            <thead>
              <tr>
                <th>客户</th>
                <th>所属成员</th>
                <th>添加时间</th>
                <th>流失状态</th>
                <th>完成情况</th>
                <th>邀请好友数</th>
                <th>操作</th>
              </tr> 
            </thead>
            <tbody id="showfuser">
             {loop $fusers as $fuser}
             <tr>
              <td>
                <div class="client-avatar">
                  <img src="{$fuser->bind_user->avatar}" alt="">
                </div>
                <span style="float: left;">{$fuser->bind_user->name}
                </span>
              </td>
              <td>
                <div class="service-card">
                  <i class="iconfont icon-person"></i>{$h->get_user_by_userid($fuser->wid,$fuser->bind_user->userid)['name']}
                </div>
              </td>
              <td>{date('Y-m-d H:i:s',$fuser->ctime)}</td>
              <td>{$fuser->bind_user->status?'正常':'流失'}</td>
              <td>{$fuser->finishStatus}</td>
              <td>{$fuser->successCount}</td>
              <td>
                <a class="table-btn" lay-event="client" onclick="etInto({$fuser->wid},'{$fuser->bind_user->external_userid}')">客户详情</a>
                <div class="divider-vertical"></div>
                <a onclick="yqInfo({$fuser->fid},{$fuser->id})" class="table-btn" lay-event="invitation">邀请详情</a>
              </td>
            </tr>
            {/loop}

          </tbody>
        </table>
        <script type="text/html" id="analysisTableClient">
          <div class="client-avatar">
            <img src="http://wx.qlogo.cn/mmhead/2hnvQgcmtJCZkny1ibV4MQwGC6PtXU2bHrQSzJJLo57U/64" alt="">
          </div>
          <span style="float: left;">{ { d.name}}
            <span class="wx">@微信</span>
          </span>
        </script>
        <script type="text/html" id="analysisTableService">
          <div class="service-card">
            <i class="iconfont icon-person"></i>李某
          </div>
        </script>
        <script type="text/html" id="analysisTableOperation">
          <a class="table-btn" lay-event="client">客户详情</a>
          <div class="divider-vertical"></div>
          <a class="table-btn" lay-event="invitation">邀请详情</a>
        </script>
      </section>
    </div>-->
  </div>
</div>

<!-- 详情面板 -->
<div hidden style="display: none;" id="missionDetailsModel">
  <section class="flex mission-details">
    <div class="mission-details-left">
      <img id="qr_code" src="" alt="">
      <p id="name">123</p>
      <div style="margin-bottom: 10px;">
        <a id="download_qrcode" target="_blank" href="" class="layui-btn layui-btn-sm layui-btn-normal">下载活码</a>
      </div>
      <!--<a href="#" class="layui-btn layui-btn-sm layui-btn-primary">修改</a>-->
    </div>
    <div class="flex-1 flex flex-column mission-details-right">
      <div class="mission-dr-inner">
        <div class="detail-item-title flex justify-start">
          <span class="item-title">
            邀请链接：
            <span class="tooltip" data-content="可复制该链接邀请用户参与裂变宝活动">
              <i class="iconfont icon-hint"></i>
            </span>
          </span>
          <div class="flex-1">
            <div class="flex link-box">
              <p class="flex-1 link" id="yq_link_show"></p>
              <button id="yq_link" data-clipboard-text="" class="layui-btn layui-btn-xs layui-btn-normal detailsCopy">复制</button>
            </div>
            <p class="tip">提示：因企业微信限制，如果客户修改了微信昵称，可能无法通过邀请链接参与活动</p>
          </div>
        </div>
        <div class="detail-item-title">
          <span class="item-title">活动时间：</span>
          <span class="date" id="dateshow"></span>
        </div>
        <div class="detail-item-title flex">
          <span class="item-title">使用成员：</span>
          <ul class="owner-list" id="usershow">

          </ul>
        </div>
        <div class="detail-item-title" id="tagshow">
          <span class="item-title">客户标签：</span>
        </div>
        <div class="detail-item-title">
          <span class="item-title">欢迎语1：</span>
          <span id="hy_text">
          </span>
        </div>
        </div>
      </div>
    </section>
  </div>

  <script src="/fission/js/jquery.min.js"></script>
  <script src="/fission/js/layui.all.js"></script>
  <script src="/fission/js/clipboard.min.js"></script>
  <script src="/fission/js/common.js"></script>
  <script src="/js/ajax.js"></script>
  <script type="text/javascript">
    // 切换表格区域
    // $('.mission_switchTable span').click(function(){
    //   console.log($(this).data('type'));
    //   $('.mission_switchTable span').removeClass('mission_switchTable_active');
    //   $(this).addClass('mission_switchTable_active');
    //   let tableType = $(this).data('type');
    //   if(tableType == "qw"){
    //     $('.mission_switchTable_secend_container').hide();
    //     $('.mission_switchTable_first_container').show();
    //   }else if(tableType == "gzh"){
    //     $('.mission_switchTable_first_container').hide();
    //     $('.mission_switchTable_secend_container').show();
    //   }
      
    // })

  </script>
  <script>
  /** layui.use('form', function(){
     var form = layui.form;
    form.on('select(mission)', function(data){
      console.log(data.elem);
      myAjaxPost(false, true, 'get_mission_statistics.html', { missionid:data.value}, function (resp) {
        if (resp.status == 'success') {
         var data = resp.data;
         $('#missionStatus').html(data.missionStatus);
         $('#allCustomer').html(data.allCustomer);
         $('#allCustomers').html('共'+data.allCustomer+'个客户');
         $('#newCustomer').html(data.newCustomer);
         $('#lossCustomer').html(data.lossCustomer);
         $('#growthCustomer').html(data.growthCustomer);
         $('#todayCustomer').html(data.todayCustomer);
         $('#completeStatus option:first').prop("selected","selected");
         $('#lostStatus option:first').prop("selected","selected");
         form.render('select');

         var fusers = data.fusers?data.fusers:[];
         showfuser(fusers);
       }else{
         alert(resp.msg);
       }
     });
   }); 
    form.on('select(completeStatus)', function(data){
      var completeStatus = data.value;
      var lostStatus = $('#lostStatus').val();
    });  
    form.on('select(lostStatus)', function(data){
      var lostStatus = data.value;
      var completeStatus = $('#completeStatus').val();
    });
  });
   function showfuser(fusers){
    $('#showfuser').empty();
    var html = '';
    for(i = 0; i < fusers.length; i++){
     html += '<tr>';
     html += '<td>';
     html += '<div class="client-avatar">';
     html += '<img src="'+fusers[i].bind_user.avatar+'" alt="">';
     html += '</div>';
     html += '<span style="float: left;">'+fusers[i].bind_user.name;
     html += '</span>';
     html += '</td>';
     html += '<td>';
     html += '<div class="service-card">';
     html += '<i class="iconfont icon-person"></i>'+fusers[i].qy_user.name;
     html += '</div>';
     html += '</td>';
     html += '<td>'+fusers[i].ctime+'</td>';
     var bustatus = fusers[i].bind_user.status == 1?"正常":"流失";
     html += '<td>'+ bustatus +'</td>';
     html += '<td>'+fusers[i].finishStatus+'</td>';
     html += '<td>'+fusers[i].successCount+'</td>';
     html += '<td>';
     html += '<a class="table-btn" lay-event="client" onclick="etInto('+fusers[i].wid+','+"'"+fusers[i].bind_user.external_userid+"'"+')">客户详情</a>';
     html += '<div class="divider-vertical"></div>';
     html += '<a onclick="yqInfo('+fusers[i].fid+','+fusers[i].id+')" class="table-btn" lay-event="invitation">邀请详情</a>';
     html += '</td></tr>';
   }
   $('#showfuser').append(html);
 }*/
</script>
<script type="text/javascript">
  function etInto(wid,etUserid){
   myAjaxPost(false, true, 'get_et_id.html', { wid:wid,etUserid:etUserid}, function (resp) {
    if (resp.status == 'success') {
     window.location.href ='/Addons/QyWechat/Admin/Externalcontact/customer_info-'+resp.data+'.html';
   }
 });
 }

 function yqInfo(fid,pid){
   layer.open({
    type: 2,
    title: '邀请详情',
    shadeClose: true,
    shade: 0.2,
    area: ['700px', '400px'],
    content: 'get_help_user_statistics-'+fid+'-'+pid+'.html'
  });
 }

 function del_mission(id){
   if(confirm('确定删除吗？')){
    myAjaxPost(false, true, 'del_mission.html', { id:id}, function (resp) {
      if (resp.status == 'success') {
       tusi(resp.msg);
       setTimeout(function(){
        location.href = 'mission_list.html';
      },500);
     }else{
       alert(resp.msg);
     }
   });
  }
}
</script>
<script>
  layui.use('laydate', function(){
    var laydate = layui.laydate;

      // 邀请日期范围
      laydate.render({
        elem: '#addTime'
        ,range: true
      });
    })

  layui.use('table', function(){
    var table = layui.table;

    table.render({
      elem: '#analysisTable'
      ,url: '/demo/table/user/'
        ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
        ,cols: [[
        { field:'id', title: '客户', templet: '#analysisTableClient'}
        ,{ field:'username', title: '所属成员', templet: '#analysisTableService'}
        ,{ field:'sex', title: '添加时间'}
        ,{ field:'city', width:120, title: '流失状态'}
          ,{ field:'sign', title: '完成情况', width: 120, minWidth: 100} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
          ,{ field:'experience', width: 120, title: '邀请好友数'}
          ,{ field:'score', width: 170, title: '操作', toolbar: '#analysisTableOperation'}
          ]]
          ,page: true
        });
  });

    // 任务详情
    layui.$('.missions-container').on('click', '.table-btn-details', function() {
      var id = layui.$(this).data('id');
      //console.log(id);
      //console.log(layui.$(this).data('others'));
      myAjaxPost(false, true, 'get_mission_detail.html', { id:id}, function (resp) {
       if (resp.status == 'success') {
        var data = resp.data;
        if(data.type == 1){
          $('#qr_code').attr('src',data.qr_code);
        }else{
          $('#qr_code').attr('src',data.code_image);
        }
        $('#name').html(data.name);
        $('#download_qrcode').attr('href','download_qrcode-'+data.id+'.html');
        $('#yq_link_show').html(data.activityurl);
        $('#yq_link').attr("data-clipboard-text",data.activityurl);
        $('#dateshow').html(data.ctime+' - '+data.end_time);
        $('#usershow').empty();
        var userhtml = '';
        for (var i = 0; i < data.users.length; i++) {
         userhtml += '<li class="owner">';
         userhtml += '<section class="avatar">';
         userhtml += '<img src="'+data.users[i].avatar+'" class="avatar-img">';
         userhtml += '</section>'+data.users[i].name;
         userhtml += '</li>';
       }
       $('#usershow').append(userhtml);
       var tagshow = '';
       for(var i = 0; i < data.select_label.length; i++){
         tagshow += '<span class="layui-badge layui-bg-blue">'+data.select_label[i]+'</span>';
       }
       $('#tagshow').append(tagshow);
       $('#hy_text').html(data.hy_text_content);
       $('#hy_link_title').html(data.hy_link_title);
       $('#hy_link_desc').html(data.hy_link_desc);
       $('#hy_link_picurl').attr('src',data.hy_link_picurl);
       lookDetails(id);
     }else{
      alert(resp.msg);
    }
  });
    });
    function lookDetails(id) {
      layer.open({
        type: 1
        ,title: '活动详情'
        ,closeBtn: true
        ,area: '688px'
        ,id: 'missionDetails' //设定一个id，防止重复弹出
        ,content: layui.$('#missionDetailsModel')
        ,success: function(layero){
          var btn = layero.find('.layui-layer-btn');
          btn.find('.layui-layer-btn0').attr({
            href: 'http://www.layui.com/'
            ,target: '_blank'
          });
        }
      })
    }

    // 任务-删除
    layui.$('.missions-container').on('click', '.table-btn-delete', function() {
      var id = layui.$(this).data('id');
      console.log(id);
      deleteMission(id)
    });
    function deleteMission(id) {
      layer.confirm('确定要删除该任务吗？', { icon: 7, title:'提示'}, function(index) {
        // confirm do something
        layer.close(index);
      });
    }

    // 初始化复制功能
    var detailsLinkClip = new ClipboardJS('.detailsCopy');
    detailsLinkClip.on('success', function() {
      layer.msg('复制成功', { icon: 1});
    })
    detailsLinkClip.on('error', function() {
      // layer.msg('复制失败', { icon: 2});
    })
    
  </script>
  <script>
    /*$(document).ready(function (){
      myAjaxPost(false, false, 'del_expire_mission.html', { }, function (resp) {
        if (resp.status == 'success') {

        }
      });
    });*/
  </script>
  <script type="text/javascript">
    $(".inner").on("click",function(){
      if($(this).prop("className") == "inner-on inner"){
        var id = $(this).data("id");
        myAjaxPost(false, true, 'update_status_kan.html', { id:id}, function (resp) {
          if(resp.status == "success"){
            tusi(resp.msg);
          }else{
            tusi(resp.msg);
          }
        })
        $(this).attr("style", "left:-51px");
        $(this).attr("class", "inner-off inner");
      }else{
        var id = $(this).data("id");
        myAjaxPost(false, true, 'update_status_guan.html', { id:id}, function (resp) {
          if(resp.status == "success"){
            tusi(resp.msg);
          }else{
            tusi(resp.msg);
          }
        })
        $(this).attr("style", "left:0px");
        $(this).attr("class", "inner-on inner");
      }
    })
  </script>
  <script>
  layui.use('form', function(){
    var form = layui.form;
    form.on('switch(switch1)', function(data){
      var id = $(this).data("id");
      if(data.elem.checked == true){
        myAjaxPost(false, true, 'update_status_kan.html', { id:id}, function (resp) {
          if(resp.status == "success"){
            tusi(resp.msg);
          }else{
            tusi(resp.msg);
          }
        })
      }else{
        myAjaxPost(false, true, 'update_status_guan.html', { id:id}, function (resp) {
          if(resp.status == "success"){
            tusi(resp.msg);
          }else{
            tusi(resp.msg);
          }
        })
      }
    }); 
    //各种基于事件的操作，下面会有进一步介绍
  });
  function copyToClip(content, message) {
      var aux = document.createElement("input"); 
      aux.setAttribute("value", content); 
      document.body.appendChild(aux); 
      aux.select();
      document.execCommand("copy"); 
      document.body.removeChild(aux);
      if (message == null) {
        layer.msg("复制成功");
      } else{
        layer.msg(message);
      }
    }
  </script>
</body>
</html>